﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_BBS_SetupBoardMaster]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_BBS_SetupBoardMaster];
GO
CREATE PROCEDURE [dbo].[sproc_BBS_SetupBoardMaster]
    @BoardID int,
    @StaffID int
/*

=================================================
功能:    设置版主
参数:
    @BoardID int        :    板块ID
    @StaffID int        :    员工ID

=================================================

*/
AS
--判断员工是否存在
IF EXISTS(SELECT 1 FROM uds_staff WHERE staff_id = @StaffID)
BEGIN
    --判断是否已经是版主
    IF NOT EXISTS(SELECT 1 FROM uds_bbs_boardmaster WHERE staff_id =@StaffID and board_id = @boardID)
        INSERT INTO uds_bbs_boardmaster (board_id,staff_id) VALUES(@boardid,@staffid)
    ELSE
        PRINT '已经是版主了!'
END
ELSE
    PRINT '不存在此人ID'